@extends('admin.common.base-master')

@section('html-head')
    <link href="{{url('css/jquery.form.css')}}" type="text/css" rel="stylesheet" />
    <script src="{{url('/js/lib/jquery.form.js')}}"></script>

    <script src="{{url('js/lib/distpicker.data.js')}}" type="text/javascript"></script>
    <script src="{{url("js/lib/distpicker.js")}}" type="text/javascript"></script>
    <style>
        .btn_add_classify{
            background: #31bcd3;margin-left:10px;height: 5px;width: 50px;color: white;text-align: center;padding:5px;border-radius:7px;box-shadow: 3px 2px 9px #888888;
        }
    </style>
    @include('UEditor::head')
@endsection

@section('html-body')
    <!-- content start -->
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>
            <a href="#">会员管理</a>
            <em>></em>
            <a href="#">添加会员</a>
        </div>
        <!-- cur-position end -->

        <div class="gg-step">
            <form  id="advform">
                <input type="hidden" name="id" id="plan_id" value=""/>

                <div class="gg-list">
                    <label class="tit">会员姓名：</label>
                    <div class="cont">
                        <input class="gg-ipt" type="text" placeholder="请输入会员姓名" name="realname" id="realname" value="" /><cite id="title_re" class="required">*</cite>
                        <p class="text">可输入2-40个字符（一个汉字等于2个字符）</p>
                    </div>
                </div>

                <div class="gg-list">
                    <label class="tit">手机号：</label>
                    <div class="cont">
                        <input class="gg-ipt" type="text" placeholder="请输入会员手机号" name="mobile" id="mobile" value="" /><cite id="title_re" class="required">*</cite>
                        <p class="text">可输入2-40个字符（一个汉字等于2个字符）</p>
                    </div>
                </div>

                <div class="gg-list">
                    <label class="tit">会员性别</label>
                    <div class="cont">
                        <select name="sex" id="sex">
                           <option value="1" selected>女</option>
                           <option value="2" selected>男</option>
                        </select>
                    </div>
                </div>

                <div class="gg-list">
                    <div class="control-group">
                        <label class="control-label">会员所在地:</label>
                        <div class="controls" id="distpicker">
                            <select tabindex="1" data-placeholder="Select here.." id="province"  selected class="span8" style="width: 20%;height: 30px;">
                                <option value=""  selected ></option>
                            </select>
                            <select tabindex="1" data-placeholder="Select here.." id="city"    selected    class="span8" style="width: 20%;height: 30px;">
                               <option value=""  selected ></option>
                            </select>
                            <select tabindex="1" data-placeholder="Select here.." id="area"   selected class="span8" style="width: 20%;height: 30px;">
                                <option value="" selected ></option>
                            </select>
                        </div>
                    </div>
                </div>

                <div class="gg-list">
                    <label class="tit">详细地址：</label>
                    <div class="cont">
                        <input class="gg-ipt" type="text" placeholder="请输入详细地址" name="info" id="info" value="" /><cite id="title_re" class="required">*</cite>
                        <p class="text">可输入2-40个字符（一个汉字等于2个字符）</p>
                    </div>
                </div>

                <div class="gg-list">
                    <label class="tit">会员来源</label>
                    <div class="cont">
                        <select name="from_type" id="from_type">
                            <option value="tmall" selected>天猫</option>
                            <option value="jd">京东</option>
                            <option value="taobao">淘宝</option>
                        </select>
                    </div>
                </div>
            </form>
            <div class="gg-list" >
                <label class="tit">&nbsp;</label>
                <div class="cont" >
                    <a href="javascript:;" class="next-step" id="btn_send">提交</a>
                </div>
            </div>
        </div>
    </div>

    <!-- content end -->
    <script>

        $(function() {

            $('#btn_send').click(function () {
                var title = $('#title').val();
                var amount = $('#amount').val();
                var select_num = $('#select_num').val();
                var invent_num = $('#invent_num').val();
                var start_time = $('#start_time').val();
                var end_time = $('#end_time').val();
                var select_time = $('#select_time').val();
                var id = $('#plan_id').val();
                var img_id2 = $('#img_id2').val();
                var videoId = $('#video_id').val();
                var upNum = $('#up_num').val();
                var author = $('#author').val();
                var desc = $('#desc').val();
                var planNum = $('#plan_num').val();
                var free_content = '';
                var content = '';

                ue.ready(function () {
                    free_content = ue.getContent();
                });

                ue2.ready(function () {
                    content = ue2.getContent();
                });

                $.ajax({
                    url: "{{route('Api.Admin.Plan.setPlan')}}",
                    type: 'post',
                    dataType: 'json',
                    data: {
                        id: id,
                        title: title,
                        amount: amount,
                        select_num: select_num,
                        invent_num: invent_num,
                        start_time: start_time,
                        end_time: end_time,
                        select_time: select_time,
                        content: content,
                        free_content: free_content,
                        up_num: upNum,
                        author: author,
                        video_id: videoId,
                        banner_id: img_id2,
                        desc: desc,
                        plan_num: planNum,
                    },
                    success: function (obj) {
                        if (obj.level == 'success') {
                            noty({
                                text: obj.message, type: obj.level, timeout: 600,
                                callback: {
                                    afterClose: function () {
                                        window.location.href = "{{route('Admin.Home.planList')}}";
                                    }
                                }
                            });
                        } else {
                            noty({text: obj.message, type: obj.level, timeout: 600});
                        }
                    },
                    error: function (obj) {
                        console.log(obj);
                    }
                });
            });

        });
    </script>
@endsection